import request from '@/utils/request'

/**
 * 获取组织结构和部门的名称
 * @returns {*}
 */
export function getAllOrganizationalStructure() {
  return request({
    url: '/organizationstructure/getOrgNameAndDeptName',
    method: 'get'
  })
}

/**
 * 根据部门ID或组织结构ID获取组织结构名称
 * @returns {*}
 * @param deptId
 * @param orgId
 */
export function getOrganizationalStructureNameByDeptID(deptId,orgId){
  return request({
    url: `/organizationstructure/getOrganizationalStructureNameByDeptID`,
    method: 'get',
    params: {deptId:deptId,orgId:orgId}
  })
}

/**
 * 根据部门ID获取部门信息
 * @returns {*}
 * @param deptId
 */
export function getDepartmentById(deptId) {
  return request({
    url: '/organizationstructure/getDepartmentById',
    method: 'get',
    params: {deptId:deptId}
  })
}

/**
 * 修改部门信息
 * @param department
 * @returns {*}
 */
export function updateDepartment(department) {
  return request({
    url: '/organizationstructure/updateDepartmentById',
    method: 'put',
    data: department
  })
}

/**
 * 删除部门信息
 * @returns {*}
 * @param deptId
 */
export function deleteDepartment(deptId) {
  return request({
    url: '/organizationstructure/deleteDepartmentById',
    method: 'delete',
    params: {deptId:deptId}
  })
}

/**
 * 根据ID获取组织结构信息
 * @param orgId
 * @returns {*}
 */
export function getOrganizationalByOrgId(orgId){
  return request({
    url: '/organizationstructure/getOrganizationalByOrgId',
    method: 'get',
    params: {orgId:orgId}
  })
}

/**
 * 修改组织结构
 * @param organization
 * @returns {*}
 */
export function updateOrganizational(organization){
  return request({
    url: '/organizationstructure/updateOrganizationalByOrgId',
    method: 'put',
    data: organization
  })
}

/**
 * 新增部门并新增与组织结构关联
 * @param department
 * @param orgId
 * @returns {*}
 */
export function addDepartment(department,orgId){
  return request({
    url: '/organizationstructure/addDepartment',
    method: 'post',
    data: department,
    params:{
      orgId:orgId
    }
  })
}

/**
 * 删除组织结构根据ID
 * @param orgId
 * @returns {*}
 */
export function deleteOrganizational(orgId){
  return request({
    url: '/organizationstructure/deleteOrganizational',
    method: 'delete',
    params: {orgId : orgId}
  })
}

/**
 * 新增组织结构
 * @param organization
 * @returns {*}
 */
export function addOrganizational(organization){
  return request({
    url: '/organizationstructure/addorganizational',
    method: 'post',
    data: organization
  })
}

